<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
selection_test(
    [
      '<div contenteditable="true" id="root">',
        '^Hello World!',
        '<div id="div">|<br></div>',
      '</div>'
    ].join(''),
    selection => {
      const div = selection.document.getElementById("div");
      selection.document.execCommand('Copy');
      selection.collapse(div, 0);
      selection.document.execCommand('Paste');
    },
    [
      '<div contenteditable="true" id="root">',
        'Hello World!',
        '<div id="div">',
          'Hello World!',
          '<div id="div">|<br></div>',
        '</div>',
      '</div>'
    ].join(''),
    'This tests for a bug where newlines would not be preserved during',
    'copy/paste. Below you should see two paragraphs containing "Hello World!"',
    'and an empty third paragraph with the caret in it.');
</script>
